import request from '@utils/request';

/** 用户登录 */
export const userLoginApi = ({ username, password }: { username: string; password: string }) => {
  return request({
    url: '/login',
    method: 'POST',
    data: { username, password }
  });
};

/** 获取当前系统信息 */
export const getSystemInfoApi = () => {
  return request({
    url: '/system/config',
    method: 'GET'
  });
};

/** 获取当前登录用户的菜单 */
export const getCurrentMenusApi = (roleId: string) => {
  return request({
    url: '/system/menu/current/tree/' + roleId,
    method: 'GET'
  });
};

export const changeRoleApi = (roleId: string) => {
  return request({
    url: '/system/user/defaultRole/' + roleId,
    method: 'PUT'
  });
};

/** 获取当前系统所有语言信息 */
export const getLanguageListApi = () => {
  return request({
    url: '/system/language',
    method: 'GET'
  });
};

/** 获取当前登录用户信息 */
export const getCurrentUserInfoApi = () => {
  return request({
    url: '/system/user/current',
    method: 'GET'
  });
};

/** 获取当前系统的菜单 */
export const getMenusApi = (params: any = {}) => {
  return request({
    url: '/system/menu/tree',
    method: 'GET',
    params
  });
};

/** 根据code(集合)获取字典数据 */
export const getDictionaryListApi = (code: string | string[] = '') => {
  return request({
    url: '/develop/dictionary/item/codes',
    method: 'GET',
    params: { codes: typeof code !== 'string' ? code.join(',') : code }
  });
};

/** 获取部门 */
export const getDeptApi = (params: any = {}) => {
  return request({
    url: '/system/dept/tree',
    method: 'GET',
    params
  });
};

/** 获取流程分类 */
export const getProcCategoryApi = (params: any = {}) => {
  return request({
    url: '/flowable/proccate',
    method: 'GET',
    params
  });
};
